﻿using System;
using NguyenHoa.Domains;
using NguyenHoa.Services;
using NguyenHoa.Web.App_Code;

namespace NguyenHoa.Web.Controls
{
  public partial class NewsCtrl : BaseControl
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        LoadNews();
      }
    }

    private void LoadNews()
    {
      TList<News> newslist = new NewsService().GetByHomeSearch(null, CurrentLanguage.Id, null, true, NewsCategoryType.Normal);
      if (newslist.Count > 0)
      {
        foreach (News news in newslist)
        {
          news.Summary = Utils.ReduceString(news.Summary, 120);
        }

        rptNews.DataSource = newslist;
        rptNews.DataBind();
      }
    }
  }
}